package cn.interceptor;

import cn.entity.User;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

import java.util.Map;

public class AuthorizationInterceptor extends AbstractInterceptor {
    @Override
    public String intercept(ActionInvocation invocation) throws Exception {
        Map session = invocation.getInvocationContext().getSession();
        User user = (User) session.get("login");
        if (user==null){
            //返回登录页面
            return Action.LOGIN;
        }else {
            //继续执行剩下的拦截器和Action
            return invocation.invoke();
        }

    }
}
